#pragma once

#include <iostream>
#include <cmath>
#include <exception>

using namespace std;

class summa
{
public:

	summa()
	{
	}

	~summa()
	{
	}

	double summa_rekursiv(int n)
	{
		if (n < 1)
		{
			throw exception("wrong input!");
		}
		else if (n == 1)
		{
			return n;
		}
		else
		{
			double s = 1 / sqrt(n);
			return s + summa_rekursiv(n - 1);
		}
	}

	double summa_iterativ(int n)
	{
		if (n < 1)
		{
			throw exception("wrong input!");
		}
		else
		{
			double summa = 0;
			for (int i = 1; i <= n; i++)
			{
				summa += 1 / sqrt(i);
			}
			return summa;
		}
	}
};

